package com.huaxin.device.models;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.huaxin.hxenum.enums.DataQuality;
import com.huaxin.hxenum.enums.DataType;
import com.huaxin.hxenum.enums.Unit;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 通用采集数据记录表（含全部公共字段，无分区）
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("collected_data_records")
@Schema(description = "采集数据记录")
public class CollectedDataRecord extends BaseModel {

    @TableField(value = "collector_id")
    @Schema(description = "采集设备ID（device_instances.id）", example = "collector-001")
    private String collectorId;

    @TableField(value = "device_serial")
    @Schema(description = "采集设备序列号", example = "SN123456789")
    private String deviceSerial;

    @TableField(value = "collector_name")
    @Schema(description = "采集设备名称冗余", example = "采集器A1")
    private String collectorName;

    @TableField(value = "equipment_id")
    @Schema(description = "被采集的电力设备ID", example = "equip-001")
    private String equipmentId;

    @TableField(value = "room_id")
    @Schema(description = "被采集的配电房ID", example = "room-001")
    private String roomId;

    @TableField(value = "cabinet_id")
    @Schema(description = "被采集的变电箱ID", example = "cabinet-001")
    private String cabinetId;

    @TableField(value = "well_id")
    @Schema(description = "被采集的电井ID", example = "well-001")
    private String wellId;

    @TableField(value = "metric_code")
    @Schema(description = "指标编码，如 100001=电压", example = "100001")
    private String metricCode;

    @TableField(value = "data_name")
    @Schema(description = "数据项名称，如 A相电压", example = "A相电压")
    private String dataName;

    @TableField(value = "unit")
    @Schema(description = "单位", example = "V")
    private Unit unit;

    @TableField(value = "value_string")
    @Schema(description = "字符串值（状态量）", example = "ON")
    private String valueString;

    @TableField(value = "value_number")
    @Schema(description = "数值型值", example = "220.5000")
    private BigDecimal valueNumber;

    @TableField(value = "value_type")
    @Schema(description = "值类型：string 或 number", example = "number")
    private DataType valueType;

    @TableField(value = "collected_at")
    @Schema(description = "数据采集时间（精确到毫秒）", example = "2025-04-05T10:30:00.123")
    private LocalDateTime collectedAt;

    @TableField(value = "received_at")
    @Schema(description = "数据接收时间", example = "2025-04-05T10:30:00.123")
    private LocalDateTime receivedAt;

    @TableField(value = "quality")
    @Schema(description = "数据质量：normal 正常，over_limit 超限，offline 离线，abnormal 异常", example = "normal")
    private DataQuality quality;
}